package com.spzx.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.common.core.utils.StringUtils;
import com.spzx.product.domain.ProductUnit;
import com.spzx.product.mapper.ProductUnitMapper;
import com.spzx.product.service.IProductUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ProductUnitServiceImpl extends ServiceImpl<ProductUnitMapper,ProductUnit> implements IProductUnitService {

    @Autowired
    ProductUnitMapper productUnitMapper;

    @Override
    public IPage<ProductUnit> getByPage(Page pageParam, ProductUnit productUnit) {
        LambdaQueryWrapper<ProductUnit> queryWrapper = new LambdaQueryWrapper<>();
        if(StringUtils.isNotEmpty(productUnit.getName())){
            queryWrapper.like(ProductUnit::getName,productUnit.getName());
        }
        return productUnitMapper.selectPage(pageParam,queryWrapper);
    }
}
